package com.rrd.dw.mr.gzip.kafka;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ucredit.babel.common.model.BaseModel;
import com.ucredit.babel.common.model.RecordType;
import com.ucredit.babel.common.model.third.bairong.BairongData;
import com.ucredit.babel.common.model.third.bairong.BairongSpecialListRecord;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper.Context;

import java.io.IOException;

/*
 * 特殊名单验证
 *
 * @author:szw
 * */

public class BaiRongSpecialListRecordParse extends ParseBase{
    private Text val = new Text();
    private Text key = new Text();

    /**
     * @param context
     * @param model
     * @param successful
     * @return
     * @throws IOException
     * @throws InterruptedException
     */

    @Override
    public boolean parseJob(Context context, BaseModel<?> model, String successful) throws IOException, InterruptedException {
        BairongSpecialListRecord brRecord = (BairongSpecialListRecord) model;
        BairongData brData = brRecord.getData() == null ? new BairongData() : brRecord.getData();

        StringBuilder sb = getBaseInfo(brRecord, successful);
        StringBuilder brSb = new StringBuilder(2000);

        JSONObject data = brData.getData() == null ? new JSONObject() : JSON.parseObject(brData.getData());
        brSb.append(data.getString("flag_specialList_c") == null ? "" : data.getString("flag_specialList_c")).append(CRT001);
        brSb.append(data.getString("sl_id_abnormal") == null ? "" : data.getString("sl_id_abnormal")).append(CRT001);
        brSb.append(data.getString("sl_id_phone_overdue") == null ? "" : data.getString("sl_id_phone_overdue")).append(CRT001);
        brSb.append(data.getString("sl_id_court_bad") == null ? "" : data.getString("sl_id_court_bad")).append(CRT001);
        brSb.append(data.getString("sl_id_court_executed") == null ? "" : data.getString("sl_id_court_executed")).append(CRT001);
        brSb.append(data.getString("sl_id_bank_bad") == null ? "" : data.getString("sl_id_bank_bad")).append(CRT001);
        brSb.append(data.getString("sl_id_bank_overdue") == null ? "" : data.getString("sl_id_bank_overdue")).append(CRT001);
        brSb.append(data.getString("sl_id_bank_fraud") == null ? "" : data.getString("sl_id_bank_fraud")).append(CRT001);
        brSb.append(data.getString("sl_id_bank_lost") == null ? "" : data.getString("sl_id_bank_lost")).append(CRT001);
        brSb.append(data.getString("sl_id_bank_refuse") == null ? "" : data.getString("sl_id_bank_refuse")).append(CRT001);
        brSb.append(data.getString("sl_id_p2p_bad") == null ? "" : data.getString("sl_id_p2p_bad")).append(CRT001);
        brSb.append(data.getString("sl_id_p2p_overdue") == null ? "" : data.getString("sl_id_p2p_overdue")).append(CRT001);
        brSb.append(data.getString("sl_id_p2p_fraud") == null ? "" : data.getString("sl_id_p2p_fraud")).append(CRT001);
        brSb.append(data.getString("sl_id_p2p_lost") == null ? "" : data.getString("sl_id_p2p_lost")).append(CRT001);
        brSb.append(data.getString("sl_id_p2p_refuse") == null ? "" : data.getString("sl_id_p2p_refuse")).append(CRT001);
        brSb.append(data.getString("sl_id_nbank_p2p_bad") == null ? "" : data.getString("sl_id_nbank_p2p_bad")).append(CRT001);
        brSb.append(data.getString("sl_id_nbank_p2p_overdue") == null ? "" : data.getString("sl_id_nbank_p2p_overdue")).append(CRT001);
        brSb.append(data.getString("sl_id_nbank_p2p_fraud") == null ? "" : data.getString("sl_id_nbank_p2p_fraud")).append(CRT001);
        brSb.append(data.getString("sl_id_nbank_p2p_lost") == null ? "" : data.getString("sl_id_nbank_p2p_lost")).append(CRT001);
        brSb.append(data.getString("sl_id_nbank_p2p_refuse") == null ? "" : data.getString("sl_id_nbank_p2p_refuse")).append(CRT001);
        brSb.append(data.getString("sl_id_nbank_mc_bad") == null ? "" : data.getString("sl_id_nbank_mc_bad")).append(CRT001);
        brSb.append(data.getString("sl_id_nbank_mc_overdue") == null ? "" : data.getString("sl_id_nbank_mc_overdue")).append(CRT001);
        brSb.append(data.getString("sl_id_nbank_mc_fraud") == null ? "" : data.getString("sl_id_nbank_mc_fraud")).append(CRT001);
        brSb.append(data.getString("sl_id_nbank_mc_lost") == null ? "" : data.getString("sl_id_nbank_mc_lost")).append(CRT001);
        brSb.append(data.getString("sl_id_nbank_mc_refuse") == null ? "" : data.getString("sl_id_nbank_mc_refuse")).append(CRT001);
        brSb.append(data.getString("sl_id_nbank_ca_bad") == null ? "" : data.getString("sl_id_nbank_ca_bad")).append(CRT001);
        brSb.append(data.getString("sl_id_nbank_ca_overdue") == null ? "" : data.getString("sl_id_nbank_ca_overdue")).append(CRT001);
        brSb.append(data.getString("sl_id_nbank_ca_fraud") == null ? "" : data.getString("sl_id_nbank_ca_fraud")).append(CRT001);
        brSb.append(data.getString("sl_id_nbank_ca_lost") == null ? "" : data.getString("sl_id_nbank_ca_lost")).append(CRT001);
        brSb.append(data.getString("sl_id_nbank_ca_refuse") == null ? "" : data.getString("sl_id_nbank_ca_refuse")).append(CRT001);
        brSb.append(data.getString("sl_id_nbank_com_bad") == null ? "" : data.getString("sl_id_nbank_com_bad")).append(CRT001);
        brSb.append(data.getString("sl_id_nbank_com_overdue") == null ? "" : data.getString("sl_id_nbank_com_overdue")).append(CRT001);
        brSb.append(data.getString("sl_id_nbank_com_fraud") == null ? "" : data.getString("sl_id_nbank_com_fraud")).append(CRT001);
        brSb.append(data.getString("sl_id_nbank_com_lost") == null ? "" : data.getString("sl_id_nbank_com_lost")).append(CRT001);
        brSb.append(data.getString("sl_id_nbank_com_refuse") == null ? "" : data.getString("sl_id_nbank_com_refuse")).append(CRT001);
        brSb.append(data.getString("sl_id_nbank_cf_bad") == null ? "" : data.getString("sl_id_nbank_cf_bad")).append(CRT001);
        brSb.append(data.getString("sl_id_nbank_cf_overdue") == null ? "" : data.getString("sl_id_nbank_cf_overdue")).append(CRT001);
        brSb.append(data.getString("sl_id_nbank_cf_fraud") == null ? "" : data.getString("sl_id_nbank_cf_fraud")).append(CRT001);
        brSb.append(data.getString("sl_id_nbank_cf_lost") == null ? "" : data.getString("sl_id_nbank_cf_lost")).append(CRT001);
        brSb.append(data.getString("sl_id_nbank_cf_refuse") == null ? "" : data.getString("sl_id_nbank_cf_refuse")).append(CRT001);
        brSb.append(data.getString("sl_id_nbank_other_bad") == null ? "" : data.getString("sl_id_nbank_other_bad")).append(CRT001);
        brSb.append(data.getString("sl_id_nbank_other_overdue") == null ? "" : data.getString("sl_id_nbank_other_overdue")).append(CRT001);
        brSb.append(data.getString("sl_id_nbank_other_fraud") == null ? "" : data.getString("sl_id_nbank_other_fraud")).append(CRT001);
        brSb.append(data.getString("sl_id_nbank_other_lost") == null ? "" : data.getString("sl_id_nbank_other_lost")).append(CRT001);
        brSb.append(data.getString("sl_id_nbank_other_refuse") == null ? "" : data.getString("sl_id_nbank_other_refuse")).append(CRT001);
        brSb.append(data.getString("sl_cell_abnormal") == null ? "" : data.getString("sl_cell_abnormal")).append(CRT001);
        brSb.append(data.getString("sl_cell_phone_overdue") == null ? "" : data.getString("sl_cell_phone_overdue")).append(CRT001);
        brSb.append(data.getString("sl_cell_bank_bad") == null ? "" : data.getString("sl_cell_bank_bad")).append(CRT001);
        brSb.append(data.getString("sl_cell_bank_overdue") == null ? "" : data.getString("sl_cell_bank_overdue")).append(CRT001);
        brSb.append(data.getString("sl_cell_bank_fraud") == null ? "" : data.getString("sl_cell_bank_fraud")).append(CRT001);
        brSb.append(data.getString("sl_cell_bank_lost") == null ? "" : data.getString("sl_cell_bank_lost")).append(CRT001);
        brSb.append(data.getString("sl_cell_bank_refuse") == null ? "" : data.getString("sl_cell_bank_refuse")).append(CRT001);
        brSb.append(data.getString("sl_cell_p2p_bad") == null ? "" : data.getString("sl_cell_p2p_bad")).append(CRT001);
        brSb.append(data.getString("sl_cell_p2p_overdue") == null ? "" : data.getString("sl_cell_p2p_overdue")).append(CRT001);
        brSb.append(data.getString("sl_cell_p2p_fraud") == null ? "" : data.getString("sl_cell_p2p_fraud")).append(CRT001);
        brSb.append(data.getString("sl_cell_p2p_lost") == null ? "" : data.getString("sl_cell_p2p_lost")).append(CRT001);
        brSb.append(data.getString("sl_cell_p2p_refuse") == null ? "" : data.getString("sl_cell_p2p_refuse")).append(CRT001);
        brSb.append(data.getString("sl_cell_nbank_p2p_bad") == null ? "" : data.getString("sl_cell_nbank_p2p_bad")).append(CRT001);
        brSb.append(data.getString("sl_cell_nbank_p2p_overdue") == null ? "" : data.getString("sl_cell_nbank_p2p_overdue")).append(CRT001);
        brSb.append(data.getString("sl_cell_nbank_p2p_fraud") == null ? "" : data.getString("sl_cell_nbank_p2p_fraud")).append(CRT001);
        brSb.append(data.getString("sl_cell_nbank_p2p_lost") == null ? "" : data.getString("sl_cell_nbank_p2p_lost")).append(CRT001);
        brSb.append(data.getString("sl_cell_nbank_p2p_refuse") == null ? "" : data.getString("sl_cell_nbank_p2p_refuse")).append(CRT001);
        brSb.append(data.getString("sl_cell_nbank_mc_bad") == null ? "" : data.getString("sl_cell_nbank_mc_bad")).append(CRT001);
        brSb.append(data.getString("sl_cell_nbank_mc_overdue") == null ? "" : data.getString("sl_cell_nbank_mc_overdue")).append(CRT001);
        brSb.append(data.getString("sl_cell_nbank_mc_fraud") == null ? "" : data.getString("sl_cell_nbank_mc_fraud")).append(CRT001);
        brSb.append(data.getString("sl_cell_nbank_mc_lost") == null ? "" : data.getString("sl_cell_nbank_mc_lost")).append(CRT001);
        brSb.append(data.getString("sl_cell_nbank_mc_refuse") == null ? "" : data.getString("sl_cell_nbank_mc_refuse")).append(CRT001);
        brSb.append(data.getString("sl_cell_nbank_ca_bad") == null ? "" : data.getString("sl_cell_nbank_ca_bad")).append(CRT001);
        brSb.append(data.getString("sl_cell_nbank_ca_overdue") == null ? "" : data.getString("sl_cell_nbank_ca_overdue")).append(CRT001);
        brSb.append(data.getString("sl_cell_nbank_ca_fraud") == null ? "" : data.getString("sl_cell_nbank_ca_fraud")).append(CRT001);
        brSb.append(data.getString("sl_cell_nbank_ca_lost") == null ? "" : data.getString("sl_cell_nbank_ca_lost")).append(CRT001);
        brSb.append(data.getString("sl_cell_nbank_ca_refuse") == null ? "" : data.getString("sl_cell_nbank_ca_refuse")).append(CRT001);
        brSb.append(data.getString("sl_cell_nbank_com_bad") == null ? "" : data.getString("sl_cell_nbank_com_bad")).append(CRT001);
        brSb.append(data.getString("sl_cell_nbank_com_overdue") == null ? "" : data.getString("sl_cell_nbank_com_overdue")).append(CRT001);
        brSb.append(data.getString("sl_cell_nbank_com_fraud") == null ? "" : data.getString("sl_cell_nbank_com_fraud")).append(CRT001);
        brSb.append(data.getString("sl_cell_nbank_com_lost") == null ? "" : data.getString("sl_cell_nbank_com_lost")).append(CRT001);
        brSb.append(data.getString("sl_cell_nbank_com_refuse") == null ? "" : data.getString("sl_cell_nbank_com_refuse")).append(CRT001);
        brSb.append(data.getString("sl_cell_nbank_cf_bad") == null ? "" : data.getString("sl_cell_nbank_cf_bad")).append(CRT001);
        brSb.append(data.getString("sl_cell_nbank_cf_overdue") == null ? "" : data.getString("sl_cell_nbank_cf_overdue")).append(CRT001);
        brSb.append(data.getString("sl_cell_nbank_cf_fraud") == null ? "" : data.getString("sl_cell_nbank_cf_fraud")).append(CRT001);
        brSb.append(data.getString("sl_cell_nbank_cf_lost") == null ? "" : data.getString("sl_cell_nbank_cf_lost")).append(CRT001);
        brSb.append(data.getString("sl_cell_nbank_cf_refuse") == null ? "" : data.getString("sl_cell_nbank_cf_refuse")).append(CRT001);
        brSb.append(data.getString("sl_cell_nbank_other_bad") == null ? "" : data.getString("sl_cell_nbank_other_bad")).append(CRT001);
        brSb.append(data.getString("sl_cell_nbank_other_overdue") == null ? "" : data.getString("sl_cell_nbank_other_overdue")).append(CRT001);
        brSb.append(data.getString("sl_cell_nbank_other_fraud") == null ? "" : data.getString("sl_cell_nbank_other_fraud")).append(CRT001);
        brSb.append(data.getString("sl_cell_nbank_other_lost") == null ? "" : data.getString("sl_cell_nbank_other_lost")).append(CRT001);
        brSb.append(data.getString("sl_cell_nbank_other_refuse") == null ? "" : data.getString("sl_cell_nbank_other_refuse")).append(CRT001);
        brSb.append(data.getString("sl_lm_cell_abnormal") == null ? "" : data.getString("sl_lm_cell_abnormal")).append(CRT001);
        brSb.append(data.getString("sl_lm_cell_phone_overdue") == null ? "" : data.getString("sl_lm_cell_phone_overdue")).append(CRT001);
        brSb.append(data.getString("sl_lm_cell_bank_bad") == null ? "" : data.getString("sl_lm_cell_bank_bad")).append(CRT001);
        brSb.append(data.getString("sl_lm_cell_bank_overdue") == null ? "" : data.getString("sl_lm_cell_bank_overdue")).append(CRT001);
        brSb.append(data.getString("sl_lm_cell_bank_fraud") == null ? "" : data.getString("sl_lm_cell_bank_fraud")).append(CRT001);
        brSb.append(data.getString("sl_lm_cell_bank_lost") == null ? "" : data.getString("sl_lm_cell_bank_lost")).append(CRT001);
        brSb.append(data.getString("sl_lm_cell_bank_refuse") == null ? "" : data.getString("sl_lm_cell_bank_refuse")).append(CRT001);
        brSb.append(data.getString("sl_lm_cell_nbank_p2p_bad") == null ? "" : data.getString("sl_lm_cell_nbank_p2p_bad")).append(CRT001);
        brSb.append(data.getString("sl_lm_cell_nbank_p2p_overdue") == null ? "" : data.getString("sl_lm_cell_nbank_p2p_overdue")).append(CRT001);
        brSb.append(data.getString("sl_lm_cell_nbank_p2p_fraud") == null ? "" : data.getString("sl_lm_cell_nbank_p2p_fraud")).append(CRT001);
        brSb.append(data.getString("sl_lm_cell_nbank_p2p_lost") == null ? "" : data.getString("sl_lm_cell_nbank_p2p_lost")).append(CRT001);
        brSb.append(data.getString("sl_lm_cell_nbank_p2p_refuse") == null ? "" : data.getString("sl_lm_cell_nbank_p2p_refuse")).append(CRT001);
        brSb.append(data.getString("sl_lm_cell_nbank_mc_bad") == null ? "" : data.getString("sl_lm_cell_nbank_mc_bad")).append(CRT001);
        brSb.append(data.getString("sl_lm_cell_nbank_mc_overdue") == null ? "" : data.getString("sl_lm_cell_nbank_mc_overdue")).append(CRT001);
        brSb.append(data.getString("sl_lm_cell_nbank_mc_fraud") == null ? "" : data.getString("sl_lm_cell_nbank_mc_fraud")).append(CRT001);
        brSb.append(data.getString("sl_lm_cell_nbank_mc_lost") == null ? "" : data.getString("sl_lm_cell_nbank_mc_lost")).append(CRT001);
        brSb.append(data.getString("sl_lm_cell_nbank_mc_refuse") == null ? "" : data.getString("sl_lm_cell_nbank_mc_refuse")).append(CRT001);
        brSb.append(data.getString("sl_lm_cell_nbank_ca_bad") == null ? "" : data.getString("sl_lm_cell_nbank_ca_bad")).append(CRT001);
        brSb.append(data.getString("sl_lm_cell_nbank_ca_overdue") == null ? "" : data.getString("sl_lm_cell_nbank_ca_overdue")).append(CRT001);
        brSb.append(data.getString("sl_lm_cell_nbank_ca_fraud") == null ? "" : data.getString("sl_lm_cell_nbank_ca_fraud")).append(CRT001);
        brSb.append(data.getString("sl_lm_cell_nbank_ca_lost") == null ? "" : data.getString("sl_lm_cell_nbank_ca_lost")).append(CRT001);
        brSb.append(data.getString("sl_lm_cell_nbank_ca_refuse") == null ? "" : data.getString("sl_lm_cell_nbank_ca_refuse")).append(CRT001);
        brSb.append(data.getString("sl_lm_cell_nbank_com_bad") == null ? "" : data.getString("sl_lm_cell_nbank_com_bad")).append(CRT001);
        brSb.append(data.getString("sl_lm_cell_nbank_com_overdue") == null ? "" : data.getString("sl_lm_cell_nbank_com_overdue")).append(CRT001);
        brSb.append(data.getString("sl_lm_cell_nbank_com_fraud") == null ? "" : data.getString("sl_lm_cell_nbank_com_fraud")).append(CRT001);
        brSb.append(data.getString("sl_lm_cell_nbank_com_lost") == null ? "" : data.getString("sl_lm_cell_nbank_com_lost")).append(CRT001);
        brSb.append(data.getString("sl_lm_cell_nbank_com_refuse") == null ? "" : data.getString("sl_lm_cell_nbank_com_refuse")).append(CRT001);
        brSb.append(data.getString("sl_lm_cell_nbank_cf_bad") == null ? "" : data.getString("sl_lm_cell_nbank_cf_bad")).append(CRT001);
        brSb.append(data.getString("sl_lm_cell_nbank_cf_overdue") == null ? "" : data.getString("sl_lm_cell_nbank_cf_overdue")).append(CRT001);
        brSb.append(data.getString("sl_lm_cell_nbank_cf_fraud") == null ? "" : data.getString("sl_lm_cell_nbank_cf_fraud")).append(CRT001);
        brSb.append(data.getString("sl_lm_cell_nbank_cf_lost") == null ? "" : data.getString("sl_lm_cell_nbank_cf_lost")).append(CRT001);
        brSb.append(data.getString("sl_lm_cell_nbank_cf_refuse") == null ? "" : data.getString("sl_lm_cell_nbank_cf_refuse")).append(CRT001);
        brSb.append(data.getString("sl_lm_cell_nbank_other_bad") == null ? "" : data.getString("sl_lm_cell_nbank_other_bad")).append(CRT001);
        brSb.append(data.getString("sl_lm_cell_nbank_other_overdue") == null ? "" : data.getString("sl_lm_cell_nbank_other_overdue")).append(CRT001);
        brSb.append(data.getString("sl_lm_cell_nbank_other_fraud") == null ? "" : data.getString("sl_lm_cell_nbank_other_fraud")).append(CRT001);
        brSb.append(data.getString("sl_lm_cell_nbank_other_lost") == null ? "" : data.getString("sl_lm_cell_nbank_other_lost")).append(CRT001);
        brSb.append(data.getString("sl_lm_cell_nbank_other_refuse") == null ? "" : data.getString("sl_lm_cell_nbank_other_refuse")).append(CRT001);
        brSb.append(data.getString("sl_lm_cell_p2p_fraud") == null ? "" : data.getString("sl_lm_cell_p2p_fraud")).append(CRT001);
        brSb.append(data.getString("swift_number") == null ? "" : data.getString("swift_number")).append(CRT001);
        brSb.append(data.getString("code") == null ? "" : data.getString("code")).append(CRT001);
        StringBuilder txSb = getBaseInfo(brRecord);
        key.set(getKey());
        val.set((sb.toString() + brSb.toString() + txSb.toString()).replace("\n", " ").replace("\r", " "));
        context.write(key, val);

        return true;
    }

    @Override
    public String getTableName() {
        return "kafka_babel_br_special_list_record_inc";
    }

    @Override
    public String getType() {
        return RecordType.BAIRONG_SPECIALLIST_FRAUD.toString();
    }

    @Override
    public String getComment() {
        return "百融特殊名单验证";
    }
}
